import Vue from "vue";
import { get, post } from "./utils/http";

const host = process.env.BASE_API;
const api = {
  host,
  indexList(p) {
    return get("/api/public/?service=Forum.GetList", p);
  },
  search(p) {
    return get("/api/public/?service=Forum.GetSearchList", p);
  },
  loadDiscuss(pId) {
    return get("/api/public/?service=Forum.GetComment", { pId: pId });
  },
  publishTopic(p) {
    return post("/api/public/?service=Forum.PostArticle", p);
  },
  getComment(pId) {
    return get("/api/public/?service=Forum.GetComment", { pid: pId });
  },
  postComment(p) {
    return post("/api/public/?service=Forum.PostComment", p);
  },
  PostCollect(pid) {
    return post("/api/public/?service=Forum.PostCollect", { pid: pid });
  },
  UpComment(cid) {
    return post("/api/public/?service=Forum.UpComment", { cid: cid });
  },
  GetCollect(p) {
    return get("/api/public/?service=Forum.GetCollect", p);
  },
  GetSysInfo() {
    get("/api/public/?service=Forum.GetSysInfo", {}).then(r => {
      let s = r.data.info.shareText;
      let allSeeNum = r.data.info.allSeeNum;
      let collectNum = r.data.info.collectNum;
      let leftSeeNum = r.data.info.leftSeeNum;
      window.sessionStorage.setItem("share", s);
      window.sessionStorage.setItem("allSeeNum", allSeeNum);
      window.sessionStorage.setItem("collectNum", collectNum);
      window.sessionStorage.setItem("leftSeeNum", leftSeeNum);
    });
  },
  PostViewVideo(pid) {
    return post("/api/public/?service=Forum.PostViewVideo", { pid: pid });
  },
  GetUserPosts(p) {
    return get("/api/public/?service=Forum.GetUserPosts", p);
  },
  GetVideoList(p) {
    return get("/api/public/?service=Forum.GetVideoList", p);
  }
  //https://doumi888.com/api/public/appapi/listAllApis.php
  //https://doumi888.com/api/public/appapi/checkApiParams.php?service=Forum.UpComment  点赞接口
  //收藏列表有了  https://doumi888.com/api/public/appapi/checkApiParams.php?service=Forum.GetCollect
  //分享 https://doumi888.com/api/public/appapi/checkApiParams.php?service=Forum.GetSysInfo
  //上报观看接口  https://doumi888.com/api/public/appapi/checkApiParams.php?service=Forum.PostViewVideo
  //我的发帖列表接口也好了 https://doumi888.com/api/public/appapi/checkApiParams.php?service=Forum.GetUserPosts
};

Vue.prototype.$api = api;
export default api;
